import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CostMachineVO, CostMachineForm, CostMachineQuery } from '@/api/agriculture/costMachine/types';

/**
 * 查询机械工时列表
 * @param query
 * @returns {*}
 */

export const listCostMachine = (query?: CostMachineQuery): AxiosPromise<CostMachineVO[]> => {
  return request({
    url: '/agriculture/costMachine/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询机械工时详细
 * @param costId
 */
export const getCostMachine = (costId: string | number): AxiosPromise<CostMachineVO> => {
  return request({
    url: '/agriculture/costMachine/' + costId,
    method: 'get'
  });
};

/**
 * 新增机械工时
 * @param data
 */
export const addCostMachine = (data: CostMachineForm) => {
  return request({
    url: '/agriculture/costMachine',
    method: 'post',
    data: data
  });
};

/**
 * 修改机械工时
 * @param data
 */
export const updateCostMachine = (data: CostMachineForm) => {
  return request({
    url: '/agriculture/costMachine',
    method: 'put',
    data: data
  });
};

/**
 * 删除机械工时
 * @param costId
 */
export const delCostMachine = (costId: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/costMachine/' + costId,
    method: 'delete'
  });
};
